#include <stdlib.h>
#include <stdio.h>
#include <allegro.h>
#include <time.h>
#include "fct.h"


int main()
{
	int i, Stime;
	Display* background=NULL;
	Plongeur p;
	BITMAP* bar;

	allegro_init();
	set_color_depth(32); //couleur 32 bits
	set_gfx_mode(GFX_AUTODETECT_WINDOWED,XMAX,YMAX,0,0); //ouvre fenetre
	install_keyboard(); //permet la gestion du clavier

	iniTabImg(&background, 1, "background", Background);
	iniTabImg(&p.display, NB_IMAGE_PLG, "0_%d", Player); //charge les images du plongeur
	Stime=clock();
	bar=load_bitmap("image/upbar.bmp",NULL);
	
	buffer = create_bitmap_ex(32, XMAX, YMAX);
	whatOnScreen = (char**) malloc (sizeof(char*)*XMAX);
	for(i=0; i < XMAX; i++)
		whatOnScreen[i] = (char*) malloc (sizeof(char)*YMAX);

	p.display->position.X=XMAX/2+1;
	p.display->position.Y=YMAX/2+1;

	while(!key[KEY_ESC])
	{
		blit(background->img->bmp,buffer,p.display->position.X-(XMAX/2),p.display->position.Y-(YMAX/2),0,0,XMAX,YMAX);
		blit(bar,buffer,0,0,18,0,26,52);
		deplacement(&p);
		AirStuff(p,Stime);
		GoUp(Stime);
		deep(p);
		process(FPS);
	}
	return 0;
}END_OF_MAIN();
